
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ include file="/include/head.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/servicePro/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/servicePro/uploadify.css">
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/problem/lytebox.js"></script>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/resources/problem/lytebox.css">
	<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/layer/layer.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/layer/extend/layer.ext.js"></script>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/resources/layer/skin/layer.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/resources/layer/skin/layer.ext.css">
<script type="text/javascript">
      $(function(){  
		   /**加载修改互动主题框**/
		  $("#update_manager_dialog").dialog({
		    autoOpen : false,
		    width : 700,
		    draggable : true,
		    resizable : false,
		    height:550,
		    buttons : [ {
		      text : "提交",
		      click : function() {
		      	  updateManager();
		     	 $(this).dialog("close");		      	
		      }
		    }, {
		      text : "取消",
		      click : function() {
		        $(this).dialog("close");
		        
		      }
		    } ]
	  });
	   /**加载添加互动主题框**/
		  $("#add_manager_dialog").dialog({
		    autoOpen : false,
		    width : 700,
		    draggable : true,
		    resizable : false,
		    height:300,
		    buttons : [ {
		      text : "提交",
		      click : function() {
		      	  addManager();
		     	 $(this).dialog("close");		      	
		      }
		    }, {
		      text : "取消",
		      click : function() {
		        $(this).dialog("close");
		        
		      }
		    } ]
	  });
	  /**添加图片框**/
		  $("#add_pic_dialog").dialog({
		    autoOpen : false,
		    width : 700,
		    draggable : true,
		    resizable : false,
		    height:300,
		    buttons : [ {
		      text : "提交",
		      click : function() {
		      	  addpic();
		     	 $(this).dialog("close");		      	
		      }
		    }, {
		      text : "取消",
		      click : function() {
		        $(this).dialog("close");
		        
		      }
		    } ]
	  });
		  $("#add_manager").click(function(e) {
	        closeOtherJDialog();
	        e.stopPropagation();
	        $("#add_manager_dialog").dialog('open');
	     });
	       $("#file_upload").uploadify({
        		    'buttonText' : '请选择活动图片',
        		    'height' : 30,
        	        'swf' : '<%=request.getContextPath()%>/resources/servicePro/uploadify.swf',
        	        'uploader' : '<%=request.getContextPath()%>/back/actBack/uploadlogo.do',
        	        'width' : 120,
        	        'multi'           : false,
                    "auto"            : false,
                    "dnd"             : true,
        	        "fileTypeExts"    : "*.png;*.jpg;*.bmp;*.gif",
                    "fileSizeLimit"   : "2MB",
        	        'fileObjName'   : 'file',
        	        'onUploadSuccess' : function(file, data, response) {
        	        	      data = eval("(" + data + ")");      	        
        	                 alert( file.name + ' 上传成功！ ');
                           $("#iphoto").val(data.picurl);
        	            $("#uploadButton").hide();
        	            
        	        },
         'onFallback' : function() {
           alert('Flash was not detected.');
        },
         "onSelect" : function(file) {
          if ($("#file_upload-queue").children().length == 1) {
            $("#uploadButton").show();
            $("#onlyOneImg").hide();
          } else {
          
            $("#uploadButton").hide();
            $("#onlyOneImg").show();
          }
        },
           "onCancel" : function() {
          if ($("#file_upload-queue").children().length == 2) {
            $("#uploadButton").show();
            $("#onlyOneImg").hide();
          } else if ($("#file_upload-queue").children().length == 1) {
            $("#uploadButton").hide();
          } else {
            $("#uploadButton").hide();
            $("#onlyOneImg").show();
          }
        },
 		        });
	     
	  });
    /**修改互动主题信息**/
     function updateManager(){
        var uid=$.trim($("#uid").val()); 
	    var utitle=$.trim($("#utitle").val());  
	    var updesc=$.trim($("#updesc").val());
	    var iifUpPic=$.trim($("#uifUpPic").val());
	    var oldphoto=$.trim($("#oldphoto").val());  
	    if(utitle.length==0  || updesc.length==0||iifUpPic.length==0||uid.length==0){
	      alert("输入信息不能为空!");
	        return false;
	    } 
	     $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/interact/updateInteractTheme.do",
				data:{"hd_id":uid,"title":utitle,"hd_desc":updesc,"ifUpPic":iifUpPic,"photo":oldphoto},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });         
     }
      /**添加互动主题信息**/
     function addManager(){
	    var ititle=$.trim($("#ititle").val());  
	    var ipdesc=$.trim($("#ipdesc").val());
	    if(ititle.length==0  || ipdesc.length==0){
	      alert("输入信息不能为空!");
	        return false;
	    } 
	     $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/interact/addInteractTheme.do",
				data:{"title":ititle,"hd_desc":ipdesc},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });            
     }
     /***添加图片**/
        function addpic(){
	    var iuid=$.trim($("#iuid").val());  
	    var iphoto=$.trim($("#iphoto").val());
	    if(iuid.length==0  || iphoto.length==0){
	      alert("输入信息不能为空!");
	        return false;
	    } 
	     $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/interact/addPic.do",
				data:{"iObj_id":iuid,"ipic_b":iphoto},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });            
     }
      /**删除选择**/
      function del(id){
         layer.open({
              type: 1,
              title: false,
              closeBtn: 2,
              shadeClose: true,
              skin: 'layui-layer-nobg',
              content: "<input style=\"width:100px;height:50px;\" class=\"common_btn jbxx_btn\"  onclick =\"delpic('"+id+"');\" type=\"button\" value=\"删除图片\">"+
                       "<input style=\"width:100px;height:50px;\" class=\"common_btn jbxx_btn\"  onclick =\"deldata('"+id+"');\" type=\"button\" value=\"删除本条数据\">"
         });
	          
      }
        /**删除图片跳转*/
        function delpic(id){
           window.location.href='<%=request.getContextPath()%>/back/interact/getActPics.do?iobj_id='+id;
        }
        /**删除本条数据*/
         function deldata(id){
          $.ajax( {
				type : "POST",
				url : "<%=request.getContextPath()%>/back/interact/delInteractTheme.do",
				data:{"iobj_id":id},
				dataType: "json",
				async : false,
				success : function(data) {
					if(data.code=="0000"){
			       		 alert("操作成功!");
			       		 location.reload();
			       }else{
			           alert(data.code+data.codeMsg);
			       }
				}
		  });      
        }

        
   </script>
<title>Document</title>


</head>
<body  >
	<div class="container">
		<div class="main_top">

			<div class="main_right fr span10">

				<div class="box pl5">
					<div class="box_border">
						<div class="box_top">
							<div class="box_top_l fl">
								<b class="pl15">数据</b>
							</div>
						</div>
						<form id="form1" method="post" action="<%=request.getContextPath()%>/back/interact/getInteractThemeBeans.do">
								<div class="searchDiv fl">
						
								<%--	<b>按互动标题搜索</b>
									 <input type="text" name="title" class="input-text lh30" style="width:300px" maxlength="50" value="${title }">  --%>
									 <b>按发布人搜索</b>
									 <input type="text" name="person" class="input-text lh30" style="width:300px" maxlength="50" value="${person }">  
									 <input type="submit" value="搜索" class="btn btn82 btn_search">

								</div>
						
							</form>
						<div class="box_center">
								<div class="searchDiv fr">
								<input type="button"  id="add_manager"  class="new_btn new_btn_publish new_btn_big" 
											value="添加数据">
								</div>
							<div id="table" class=" fl mt10">
								<div class="box span10 oh">
									<table width="100%" border="0" cellpadding="0" cellspacing="0"
										class="list_table">
										<tr>
											<th width="1%">序号</th>
											<%--<th width="3%">标题</th>--%>
											<th width="2%">缩略图</th>
											<th width="2%">发布人</th>
											<th width="2%">创建时间</th>
											<th width="2%">是否有效</th>
											<th width="3%">添加图片</th>
											<th width="2%">查看图片</th>
											<th width="5%">操作</th>
										</tr>
										<c:if test="${fn:length(interList)==0}"><tr class="tr"><td align="center" colspan="8">暂无数据</td> </tr></c:if>
										<c:if test="${fn:length(interList)>0}">
										<c:forEach items="${interList}" var="dic" varStatus="abc">
											<tr class="tr">
											    <td align="center"><c:out value="${(PageBean.currentpage-1)*PageBean.pagesize+abc.index + 1}" /></td>
											   <%-- <td align="center"><c:out value="${dic.title}" /></td>--%>
											    <td align="center">
                                                    <IMG alt="缩略图" width="50" height="50" src="<%=imgPath %>${dic.photo}"/>
                                                 </td>
                                                 <td align="center">
                                                    <c:out value="${dic.username}" />
                                                 </td>
                                                  <td align="center">
                                                    <c:out value="${dic.create_time}" />
                                                 </td>
												<td align="center">
												 <c:if test="${dic.is_eff == 0 }">无效</c:if>
												 <c:if test="${dic.is_eff == 1 }">有效</c:if>
                                                </td>
                                                 <td align="center">
												  <input type="button" class="new_btn new_btn_publish new_btn_big" value="添加图片"  />
                                                </td>
											     	<td align="center"><c:if
															test="${fn:length(dic.listPic)>0}">
															<c:forEach items="${dic.listPic}" var="pic" varStatus="abcd">
																<div class="thumbnail">
																	<a href="<%=imgPath %>${pic.pic_b}" rel="lytebox[plants]${dic.hd_id }" title="Press X to close"><img/></a>
																</div>
																<c:if test="${abcd.index==0}">
																<input type="button" class="new_btn new_btn_look new_btn_big" value="查看图片"  />
																</c:if>
																</a>
															</c:forEach>
														</c:if> <c:if test="${fn:length(dic.listPic)==0}">
															暂无图片
															</c:if>
													</td>
												<td align="center">
												 <%-- <input type="button" class="new_btn new_btn_up" value="更新" onclick="update('${dic.hd_desc}')"  >--%>
												   <input type="button" class="new_btn new_btn_delete" value="删除"  onclick="javascript:del('${dic.hd_id }');" >
													<c:if test="${dic.up > 1000}">
														<input type="button" class="new_btn new_btn_change" value="取消置顶"  onclick="javascript:cancelUp('${dic.hd_id}');" >
													</c:if>
													<c:if test="${dic.up == 1000}">
														<input type="button" class="new_btn new_btn_up" value="置顶"  onclick="javascript:up('${dic.hd_id}');" >
													</c:if>
												  </td>
												 <td style="display:none;"><c:out value="${dic.hd_id}" /></td>
												  <td style="display:none;"><c:out value="${dic.photo}" /></td>
												  <td style="display:none;"><c:out value="${dic.hd_desc}" /></td>  
											</tr>
										</c:forEach>
                                     </c:if>
									</table>
									<div class="fr fontblack mt25 mb20 mr20">
										每页条数：<a href="<%=request.getContextPath()%>/back/interact/getInteractThemeBeans.do?pz=5"
											class="${pageSize == 5 ? 'fontpink' : ''}">5</a> | <a
											href="<%=request.getContextPath()%>/back/interact/getInteractThemeBeans.do?pz=10"
											class="${pageSize == 10 ? 'fontpink' : ''}">10</a> | <a
											href="<%=request.getContextPath()%>/back/interact/getInteractThemeBeans.do?pz=20"
											class="${pageSize == 20 ? 'fontpink' : ''}">20</a>
									</div>
									<div class="fr fontblack mt5 mb20 mr20">
										<jsp:include page="../template/commonPagination.jsp">
											<jsp:param name="url" value="getInteractThemeBeans.do?"></jsp:param>
										</jsp:include>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="clear"></div>
		</div>

	</div>
	
 <script type="text/javascript">
	     $("#table tr").on("click", "td:eq(7) input:eq(0)", function(e) {
	        closeOtherJDialog();
	        e.stopPropagation();
	        var dialog =  $("#update_manager_dialog");
	         dialog.dialog("open");
              var tr = $(this).parent().parent();
		      tr.data("tdArr", ["td:eq(8)","td:eq(1)","td:eq(10)","td:eq(9)"]);
		      tr.data("inputArr", ["input:eq(0)","input:eq(1)","textarea:eq(0)","input:eq(2)"]);
		      for (var i = 0, length = tr.data("tdArr").length; i < length; i++) {
		       $(tr.data("inputArr")[i], dialog).val($.trim($(tr.data("tdArr")[i], tr).text()));
		 }
   
	     });
	     
	      $("#table tr").on("click", "td:eq(5) input:eq(0)", function(e) {
	        closeOtherJDialog();
	        e.stopPropagation();
	        var dialog =  $("#add_pic_dialog");
	         dialog.dialog("open");
              var tr = $(this).parent().parent();
		      tr.data("tdArr", ["td:eq(8)"]);
		      tr.data("inputArr", ["input:eq(0)"]);
		      for (var i = 0, length = tr.data("tdArr").length; i < length; i++) {
		       $(tr.data("inputArr")[i], dialog).val($.trim($(tr.data("tdArr")[i], tr).text()));
		 }
   
	     });
  </script> 
		<!-- 添加互动主题信息 -->
		<div id="add_manager_dialog" title="添加互动主题信息" style="display:none;">
		<div class="box span10 oh">
			<table class="list_table"  id="tb_version_update" >
			   <tr class="tr">
				<%--	<td align="left">&nbsp;&nbsp;互动主题:</td>
					<td>
					  <input type="text" id="ititle" name="ititle" class="input-text_popup_form" style="width:300px" maxlength="50">
				   </td>--%>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;互动描述:</td>
					<td>
					   <textarea   id="ipdesc" class="input-text_popup_form pl10 ml10"
						style="height:100px;width:90%;"></textarea>
					</td>
				</tr>
			</table>
		</div>
		</div>
		<!-- 修改互动主题信息 -->
		<div id="update_manager_dialog" title="修改互动主题信息 " style="display:none;">
		<div class="box span10 oh">
		<input type="hidden" id="uid"   />
			<table class="list_table"  id="tb_version_update" >
			  <%--<tr class="tr">
					<td align="left">&nbsp;&nbsp;互动主题:</td>
					<td> 
					  <input type="text" id="utitle" name="utitle" class="input-text_popup_form" style="width:300px" maxlength="50">
				    </td>
				</tr>--%>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;互动描述:</td>
					<td>
					   <textarea   id="updesc" class="input-text_popup_form pl10 ml10"
						style="height:100px;width:90%;"></textarea>
						
					</td>
				</tr>
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;是否删除缩略图:</td>
					<td><select id="uifUpPic" name="uifUpPic" class="select pd10">
					<option value="0">否</option>
					<option value="1">是</option>
					</select>
					<input type="hidden" id="oldphoto"   />
				</td>
				</tr>
			</table>
		</div>
		</div>
		<!-- 添加图片 -->
		<div id="add_pic_dialog" title="添加图片 " style="display:none;">
		<div class="box span10 oh">
		<input type="hidden" id="iuid"   />
			<table class="list_table"  id="tb_version_update" >
				<tr class="tr">
					<td align="left">&nbsp;&nbsp;缩略图片:</td>
					<td>
					<div>
					<input type="hidden" id="iphoto"   />
							<input type="file" name="fileName" class="ml10" style="height:36px;" id="file_upload" />
							<input id="uploadButton" type="button"
								onclick="$('#file_upload').uploadify('upload');" value="开始上传"
								class="ext_btn ext_btn_success" style="display:none;">
							<p class="fontpink" id="onlyOneImg" style="display:none;">只能上传一张图片</p>
							</div>
                    </td>
				</tr>
			</table>
		</div>
		</div>
		<script type="application/javascript">
			function up(uid) {
				$.ajax( {
					type : "POST",
					url : "<%=request.getContextPath()%>/back/interact/topInteractTheme.do",
					data:{"iobj_id":uid},
					dataType: "json",
					async : false,
					success : function(data) {
						if(data.code=="0000"){
							alert("操作成功!");
							location.reload();
						}else{
							alert(data.code+data.codeMsg);
						}
					}
				});
			}
			function cancelUp(uid) {
				$.ajax( {
					type : "POST",
					url : "<%=request.getContextPath()%>/back/interact/cancelUp.do",
					data:{"iobj_id":uid},
					dataType: "json",
					async : false,
					success : function(data) {
						if(data.code=="0000"){
							alert("操作成功!");
							location.reload();
						}else{
							alert(data.code+data.codeMsg);
						}
					}
				});
			}
			function update(detail) {
				$('#ipdesc').val(detail);
			}
		</script>
</body>
</html>
